/*
 * InputField.hpp
 *
 *  Created on: 12-12-2010
 *      Author: Przemek
 */

#pragma once

#include "Control.hpp"
#include "KeyListener.hpp"
#include "pch.hpp"

class InputField: public Control
{
	public:
		class Validator
		{
			public:
				virtual bool isValid(const std::string& text) const = 0;
		};

		class IntegerNumberValidator: public Validator
		{
			public:
				bool isValid(const std::string& text) const;
		};

		class FloatNumberValidator: public Validator
		{
			public:
				bool isValid(const std::string& text) const;
		};

	private:
		boost::shared_ptr<Validator> validator;
		std::string text;

	public:
		void setManagedValidator(Validator* validator);
		void draw();

	private:
		void keyPressed(const KeyListener::EventArguments& arguments);
		bool isValidInserCharacter(char character);
};

